<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@page import="java.util.List"%>
<%@page import="com.demoweb.model.dto.Board"%>
<%@page import="com.demoweb.model.dto.Membership"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Red Fortress</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="/demoweb/styles/style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<%
	pageContext.include("/WEB-INF/views/include/fortressheader.jsp");
%>

<div id="content">
  <div id="sidebar">
    <div id="login" class="boxed">
      <h2 class="title">Client Account</h2>
      <div class="content">     
	  
		 <%
     	  		 	if (request.getParameter("returnuri") != null) {
     	  		 %>
		        <%-- <input type="hidden" .. /> : 눈에 보이지 않는 입력 요소 --%>
		        <%
		        	String query = request.getParameter("pageno");
		        		           String returnuri = request.getParameter("returnuri");
		        		   if(query != null && query.length() != 0) {
		        		  	 if(returnuri.contains("?")) {
		        			   	query="&pageno=" + query;
		        		  	 } else {
		        				   query="?pageno=" + query;
		        		   	 }
		        		   } else {
		        			   query = "";
		        		   }
		        %>
		        <input type="hidden" name="returnuri" value='<%=returnuri + query%>' />
		 <%
		 	}
		 %>
		        
		<%
		        			if(session.getAttribute("loginuser") == null)  {
		        		%>
		<form id="loginform" method="post" action="fortressLogin.nhn">  
          <fieldset>
          <legend>Login</legend>
          <label for="inputtext1">Client ID:</label>
          <input id="inputtext1" type="text" name="memberId" value="" />
          <label for="inputtext2">Password:</label>
          <input id="inputtext2" type="password" name="passwd" value="" />
          <input id="inputsubmit1" type="submit" name="inputsubmit1" value="Login" />
          <p><a href="">Forgot your password?</a></p>
          </fieldset>
        </form>
	 	<%
	 		} else {
	 	%>	 
	 	<form id="loginform" method="post" action="fortressLogin.nhn">  
          <fieldset>
          <legend>Login</legend>
          	 <%
          	 	Membership member = (Membership)session.getAttribute("loginuser");
          	 %>
			 <a2> <%=member.getMemberId()%> 님 환영합니다. </a2>
			 <a href="/demoweb/fortress/fortressLogout.nhn"> 로그아웃 </a></br>
		 	 <input type="button" value="Start" style="width:200px" style="hegiht:50px" onclick="location.href='.action';" />
		 <%
		 	}
		 %>      
          </fieldset>
        </form>
        
      </div>
    </div>    
	<%
    		pageContext.include("/WEB-INF/views/include/fortressrecentupdates.jsp");
    	%>	
  </div>
  
  <!-- ---------------------------------- Main page content ----------------------------------- -->
  <div id="main"> 
  	  <h2 class="title">Fortress Board</h2>
  	  	<title>글쓰기</title>
			<link rel="Stylesheet" href="/demoweb/styles/input.css" />
			<script type="text/javascript">
			function doDelete(boardno) {
			var ok = confirm("게시물을 삭제 합니다.");
			if (ok) {
				//삭제 처리
				location.href="delete.action?boardno=" + boardno;
			}
		}
		</script>

	<div id="pageContainer">	
		<div style="padding-top:25px;text-align:center">
		<div id="inputcontent">
		    <div id="inputmain">
		        <div class="inputsubtitle">게시판 글 내용</div>
		        <%
		        	Board board = (Board)request.getAttribute("board");
		        %>
		        <table>
		            <tr>
		                <th>제목</th>
		                <td><%=board.getTitle()%></td>
		            </tr>
		            <tr>
		                <th>작성자</th>
		                <td><%=board.getWriter()%></td>
		            </tr>
		            <tr>
		                <th>작성일</th>
		                <td><%=board.getRegDate()%></td>
		            </tr>
					<tr>
		                <th>조회수</th>
		                <td><%=board.getReadCount()%></td>
		            </tr>
		            <tr>
		                <th>내용</th>
		                <td style="height:200px;vertical-align:top">		                    
		                    <%=board.getContent().replace("\r\n", "<br />")%>
		                </td>
		            </tr>
		        </table>
		        <div class="buttons">
		        	<%
		        		String pageNo = request.getParameter("pageno");
		        			        		if (pageNo == null || pageNo.length() == 0)
		        			        			pageNo = "1";
		        	%>
		        	<%
		        		Membership member = (Membership)session.getAttribute("loginuser");
		        	%>
		        	<% if (member.getMemberId().equals(board.getWriter())) { %>
		        	[&nbsp;<a href="editform.action?boardno=<%= board.getBoardNo() %>&pageno=<%= pageNo %>">편집</a>&nbsp;]
		        	[&nbsp;<a href="javascript:doDelete(<%= board.getBoardNo() %>);">삭제</a>&nbsp;]
		        	<% } %>
		        	[&nbsp;<a href="replyform.action?boardno=<%= board.getBoardNo() %>&pageno=<%= pageNo %>">댓글쓰기</a>&nbsp;]
		        	[&nbsp;<a href='list.action?pageno=<%= pageNo %>'>목록보기</a>&nbsp;]
		        </div>
		    </div>
		</div>
	
	</div>
	</div>

      
  </div>
  <!-- -------------------------------------------------------------------------------------------- -->
  
</div>
<div id="footer">
  <p id="legal">Copyright &copy; 2007 Red Avenue. All Rights Reserved. Designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
  <p id="links"><a href="http://www.free-css.com/">Home</a> | <a href="http://www.free-css.com/">Terms of Use</a></p>
</div>
</body>
</html>
